*********************************************************
*********************************************************  
*** GBR 2024 --- JPE Revision Package *******************
*** Code to prepare the dataset of Study 3 **************
*** Public (anonymized) *********************************
*********************************************************

** Note: this code is use for cleaning the dataset for Study 3 for it being
* used together with the datasets of Studies 1 and 2. It has been already 
* pre-cleaned before, including for anonymization.

clear all
use ".../JPEReplicationPackageDataverse/GBR24DataStudy3.dta"

set more off

destring, replace

** Create control variables
* Age categories (age variable from Prolific)
gen age60=0  if age!=.
replace age60=1 if age>=60 & age!=.
gen age50=0 if age!=.
replace age50=1 if age>=50 & age<60
gen age40=0  if age!=.
replace age40=1 if age>=40 & age<50
label variable age40 "Age 40-49 indicator: 0No 1Yes"
label variable age50 "Age 50-59 indicator: 0No 1Yes"
label variable age60 "Age 60+ indicator: 0No 1Yes"

* Ethnicity: white vs. non-white indicator
gen white=0 if ethnicity!=""
replace white=1 if ethnicity=="White"
replace white=. if  ethnicity=="CONSENT REVOKED"
label variable white "White (vs. non-white) indicator: 0No 1Yes"


* Re-code and re-scale questionnaire questions post experiment, common Studies 1--3
* PE1, understand instructions
gen PE1_UnderstandInst=PE1-1
label variable PE1_UnderstandInst "Common: Understood instructions scale: 0 (not at all) to 6 (very well)"
* PE3, trust instructions
gen PE3_TrustInst=PE3-1
label variable PE3_TrustInst "Common: Trusted instructions scale: 0 (not at all) to 6 (completely)"
* PE4, discussed study before participating
gen PE4_DiscussSomeoneElse=PE4-1
label variable PE4_DiscussSomeoneElse "Common: Discussed study with other Prolific user who participated before study: 0No 1Yes"
* PE5, helped by someone else
gen PE5_HelpSomeoneElse=PE5-1
label variable PE5_HelpSomeoneElse "Common: Completed this study with the help of someone else: 0No 1Yes"
* PE6, participated in similar experiment before
gen PE6_ParticipatedSimilarExp=PE6-1
label variable PE6_ParticipatedSimilarExp "Common: Participated in similar experiment before: 0No 1Yes"
* PE7, knew someone else participating in same experiment
gen PE7_KnowSomeoneElse=PE7-1
label variable PE7_KnowSomeoneElse "Knew someone participating in same experiment: 0No 1Yes"
* PE9, believe gender discrimination was used in the study
gen PE9_UsedDiscrimination=PE9-1
label variable PE9_UsedDiscrimination "Believed gender discr was used in study: 0 (not at all) to 6 (completely)"
* PE10, believed could reward experimenters by completing more lines or hurt them by completing fewer lines
gen PE10_BeliefReward_withmorelines=PE10-1
label variable PE10_BeliefReward_withmorelines "Believed reward experimenter with lines: 0 (not at all) to 6 (completely)"
* PE11, believed other (paired) participant exists
gen PE11_BelOtherExists=PE11-1
label variable PE11_BelOtherExists "Believed other (paired) participant exists: 0 (not at all) to 6 (completely)"
* PE12, previous experience of discrimination (outside experiment, PE12:6 means participant did not want to answer)
gen PE12_PreviouslyDiscriminated=PE12-1 if PE12!=6
label variable PE12_PreviouslyDiscriminated "Previous experience of gender disc: 0 (not at all) to 4 (a great deal)"
* PE13, previous experience of discrimination in workplace (PE13:6 means participant did not want to answer)
gen PE13_PreviouslyDiscriminatedWork=PE13-1 if PE13!=6 
label variable PE13_PreviouslyDiscriminatedWork "Previous workplace experience of gender disc: 0 (not at all) to 4 (a great deal)"
* PE14, belief how much women earn vs. men, on average in UK for full-time job
gen PE14_GenderEarningGapOverall=PE14-1 if PE14!=16 & PE14!=17
label variable PE14_GenderEarningGapOverall "Belief wom earn vs man, fulltime job: 0(65%-) 7(100%) 14(135%+)"
* PE15, belief how much women earn vs. men doing the same full-time job with the same work characteristics (e.g., competence, education, hours worked, management skills, productivity), on average in UK
gen PE15_GenderEarningGapSameWorkers=PE15-1 if PE15!=16 & PE15!=17
label variable PE15_GenderEarningGapSameWorkers "Belief wom earn vs man w/ same charact, fulltime job: 0(65%-) 7(100%) 14(135%+)"
* PE16, belief regarding how much gender disc there is in UK today
gen PE16_BeliefGenderDiscUKToday=PE16-1 if PE16!=8 & PE16!=9
label variable PE16_BeliefGenderDiscUKToday "UK gender disc today: 0(men strong disc against)-6(wom strong disc against)"
* PE17, for or against preferential hiring and promotion of women
gen PE17_PreferentialTreatmentWom=PE17-1 if PE17!=6 & PE17!=7
label variable PE17_PreferentialTreatmentWom "Preferential hiring/promotion of wom: 0(strong against)-4(strong for)"
* PE18, agree or disagree that both husband and wife should contribute to household income
gen PE18_HusbWifeShouldContInc=PE18-1 if PE18!=6 & PE18!=7
label variable PE18_HusbWifeShouldContInc "Both husband/wife should contribute to hous inc: 0(strong disag)-4(strong agree)"
* PE19, agree or disagree that job is alright, but what most women really want is home and children
gen PE19_WomWantHomeChildren=PE19-1 if PE19!=6 & PE19!=7
label variable PE19_WomWantHomeChildren "What wom really want is home+children: 0(strong disag)-4(strong agree)"
* PE20, agree or disagree that most men are better suited emotionally for politics than are most women
gen PE20_MenBetterSuitedPolitics=PE20-1 if PE20!=6 & PE20!=7
label variable PE20_MenBetterSuitedPolitics "Men better suited emotionally for politics: 0(strong disag)-4(strong agree)"

* PE10_2, believed could hurt experimenters by completing more lines or reward them by completing fewer lines
gen PE10_BeliefPunish_withmorelines=PE10_2-1
label variable PE10_BeliefPunish_withmorelines "Believed reward experimenter with lines: 0 (not at all) to 6 (completely)"
* PNE1, emotions (intensity of each emotion, rescale: 0 to 6)
gen intensity_anger=PEN1_anger-1
label variable intensity_anger "How intensely felt anger: 0 (not at all) to 6 (very intensely)"
gen intensity_surprise=PEN1_surprise-1
label variable intensity_surprise "How intensely felt surprise: 0 (not at all) to 6 (very intensely)"
gen intensity_happiness=PEN1_happiness-1
label variable intensity_happiness "How intensely felt happiness: 0 (not at all) to 6 (very intensely)"
gen intensity_disgust=PEN1_disgust-1
label variable intensity_disgust "How intensely felt disgust: 0 (not at all) to 6 (very intensely)"
gen intensity_sadness=PEN1_sadness-1
label variable intensity_sadness "How intensely felt sadness: 0 (not at all) to 6 (very intensely)"
gen intensity_fear=PEN1_fear-1
label variable intensity_fear "How intensely felt fear: 0 (not at all) to 6 (very intensely)"
gen intensity_guilt=PEN1_guilt-1
label variable intensity_guilt "How intensely felt guilt: 0 (not at all) to 6 (very intensely)"
gen intensity_irritation=PEN1_irritation-1
label variable intensity_irritation "How intensely felt irritation: 0 (not at all) to 6 (very intensely)"
gen intensity_gratitude=PEN1_gratitute-1
label variable intensity_gratitude "How intensely felt gratitute: 0 (not at all) to 6 (very intensely)"
* PEN2, motivation (or work morale) during task (rescale: 0 to 6)
gen work_moral_motivation=PEN2-1
label variable work_moral_motivation "Motivated to work during task: 0 (not at all) to 6 (completely)"
* PEN3, frustration during task (rescale: 0 to 6)
gen work_moral_frustrated=PEN3-1
label variable work_moral_frustrated "Felt frustrated during task: 0 (not at all) to 6 (completely)"

* Create indicator for UK nationality
gen nat_uk=0
replace nat_uk=1 if nationality=="United Kingdom" 
label variable nat_uk "Nationality indicator: 0Non-UK 1UK"

* Create indicator for students
gen student=0 if student_status=="No"
replace student=1 if student_status=="Yes"
label variable student "Student indicator: 0No 1Yes"

* Create employment status indicators
gen employed=.
replace employed=1 if employment_status=="Full-Time"
replace employed=0 if employment_status=="Not in paid work (e.g. homemaker', 'retired or disabled)"
replace employed=0 if employment_status=="Other"
replace employed=0 if employment_status=="Due to start a new job within the next month"
replace employed=0 if employment_status=="Part-Time"
replace employed=0 if employment_status=="Unemployed (and job seeking)"
label variable employed "E: Employed full time indicator: 0No 1Yes"

gen unemployed=.
replace unemployed=0 if employment_status=="Full-Time"
replace unemployed=0 if employment_status=="Not in paid work (e.g. homemaker', 'retired or disabled)"
replace unemployed=0 if employment_status=="Other"
replace unemployed=0 if employment_status=="Due to start a new job within the next month"
replace unemployed=0 if employment_status=="Part-Time"
replace unemployed=1 if employment_status=="Unemployed (and job seeking)"
label variable unemployed "E: Unemployed indicator: 0No 1Yes"

gen parttime=.
replace parttime=0 if employment_status=="Full-Time"
replace parttime=0 if employment_status=="Not in paid work (e.g. homemaker', 'retired or disabled)"
replace parttime=0 if employment_status=="Other"
replace parttime=0 if employment_status=="Due to start a new job within the next month"
replace parttime=1 if employment_status=="Part-Time"
replace parttime=0 if employment_status=="Unemployed (and job seeking)"
label variable parttime "E: Employed part time indicator: 0No 1Yes"

gen notInPaidJob=.
replace notInPaidJob=0 if employment_status=="Full-Time"
replace notInPaidJob=1 if employment_status=="Not in paid work (e.g. homemaker', 'retired or disabled)"
replace notInPaidJob=0 if employment_status=="Other"
replace notInPaidJob=0 if employment_status=="Due to start a new job within the next month"
replace notInPaidJob=0 if employment_status=="Part-Time"
replace notInPaidJob=0 if employment_status=="Unemployed (and job seeking)"
label variable notInPaidJob "E: Not in paid job indicator: 0No 1Yes"

gen otheremployment=.
replace otheremployment=0 if employment_status=="Full-Time"
replace otheremployment=0 if employment_status=="Not in paid work (e.g. homemaker', 'retired or disabled)"
replace otheremployment=1 if employment_status=="Other"
replace otheremployment=1 if employment_status=="Due to start a new job within the next month"
replace otheremployment=0 if employment_status=="Part-Time"
replace otheremployment=0 if employment_status=="Unemployed (and job seeking)"
label variable otheremployment "E: Other employement status indicator: 0No 1Yes"

** Create variable to identify each study, and ID variable (3,000,000 range 
* denotes IDs in Study 3)
gen study=3
gen id=3000000 + _n
label variable study "Study: 1Study1 2Study2 3Study3 4Study4 5Study5 6Study6"
label variable id "Worker ID: 1,000,000 range for Study 1, 2,000,000 for Study 2,..."

** Create alternative wage variable
gen w=3 if low_wage==1
replace w=6 if high_wage==1
label variable w "Piece-rate wage in approx. 2018 equivalent: 3(low-wage) 6(high-wage)"

** Create inequality aversion variables (for parameter estimation in Appendix)
gen dis_ineq=0 
replace dis_ineq=6-3 if low_unequal==1
label variable dis_ineq "Disadvantageous piece-rate wage inequality"
gen adv_ineq=0
replace adv_ineq=6-3 if high_unequal==1
label variable adv_ineq "Advantageous piece-rate wage inequality"
gen d_dis_ineq=0 
replace d_dis_ineq=6-3 if low_disc==1
label variable d_dis_ineq "Gender-disc disadvantageous piece-rate wage inequality"
gen d_adv_ineq=0
replace d_adv_ineq=6-3 if high_disc==1
label variable d_adv_ineq "Gender-disc advantageous piece-rate wage inequality"

* Standardize labor supply based on unequal low wage scheme (mean 46.06977, sd 23.82111)
sum l if low_unequal==1 & study==3
gen sd_l=(l-46.06977)/23.82111 if study==3
label variable sd_l "Standardized labor supply (based on UnEq low-wage workers)"

* Standardize labor supply by gender based on unequal low wage scheme of each gender (men: mean 46.44667, sd 24.85192; women: mean 45.69536, sd 22.82776)
sum l if low_unequal==1 & study==3 & woman==0
sum l if low_unequal==1 & study==3 & woman==1
gen sd_l_gender=(l-46.44667)/24.85192 if study==3 & woman==0
replace sd_l_gender=(l-45.69536)/22.82776 if study==3 & woman==1
label variable sd_l_gender "Gender-standardized labor supply (based on UnEq low-wage workers of each gender)"

* Provide info in label for three comprehension questions
label variable C2  "1st ans. to compr. quest. on what the task is, correct:3"
label variable C4 "1st ans. to compr. quest. on whether task has further uses for anyone, correct:4"
label variable C9 "1st ans. to compr. quest. on how we pay workers, correct:3"


** Save dataset
save ".../JPEReplicationPackageDataverse/GBR24DataCleanStudy3.dta", replace
